package Z11_12_customizedPool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;


/**
 * @author： pang-yun
 * @date： 2021-11-16 12:00
 * 功能目的 ：用于  线程池实现  以及 线程工厂的重写
 */
/**
 * [Pang-1] INFO Z11_12_customizedPool.ScheduledExecutor - Pang
 * [Pang-1] INFO Z11_12_customizedPool.ScheduledExecutor - Chao
 * [Pang-1] INFO Z11_12_customizedPool.ScheduledExecutor - Jie
 */

@Slf4j
public class ScheduledExecutor {
    public static void main(String[] args) {

        ExecutorService pool = Executors.newFixedThreadPool(2, new ThreadFactory() {
            private AtomicInteger integer = new AtomicInteger(1);
            @Override
            public Thread newThread(Runnable r) {
                return new Thread(r,"Pang-"+integer.getAndIncrement());
            }
        });

        pool.execute(()->{
            log.info("Pang");
        });

        pool.execute(()->{
           log.info("Chao");
        });

        pool.execute(()->{
            log.info("Jie");
        });

    }
}
